Closures in Lua

نویسندگان

  • Roberto Ierusalimschy
  • Luiz Henrique de Figueiredo
  • Waldemar Celes
چکیده

First-class functions are a very powerful language construct and a fundamental feature in functional languages. However, few procedural languages support this feature, due to their stack-based implementation. In this paper we discuss a new algorithm for the implementation of first-class functions used in the implementation of Lua 5.x. Unlike previous techniques, our algorithm does not need static analysis of the source code (a luxury that the on-the-fly Lua code generator cannot afford) and does not prevent the use of an array-based stack to store regular local variables.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

The Implementation of Lua 5.0

We discuss the main novelties of the implementation of Lua 5.0: its register-based virtual machine, the new algorithm for optimizing tables used as arrays, the implementation of closures, and the addition of coroutines.

متن کامل

Static Analysis of Lua using Interface Models

Game development businesses often choose Lua for separating scripted game logic from reusable engine code. Lua can easily be embedded, has simple interfaces, and offers a powerful and extensible scripting language. Using Lua, developers can create prototypes and scripts at early development stages. However, when larger quantities of engine code and script are available, developers encounter mai...

متن کامل

First-Class Functions in an Imperative World

First-class functions are a hallmark of functional languages, but they are a useful concept in imperative languages, too. Even ANSI C offers a restricted form of first-class functions (in the form of pointers to functions), and several more recent imperative languages, such as Python 3, Go, Lua, and Swift, offer first-class, anonymous functions with lexical scoping. In most imperative languages...

متن کامل

The Evolution of an Extension Language: A History of Lua

Since its inception, in 1993, the Lua programming language has gone far beyond our most optimistic expectations. In this paper, we describe the trajectory of Lua, from its creation as an in-house language for two specific projects, until Lua 4.0, released in November 2000. We discuss the evolution of some of its concepts and the main landmarks in its

متن کامل

The TEX – Lua mix

An introduction to the combination of TEX and the scripting language Lua.

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2013